import { createContext, useContext } from 'react';

interface RouterRefreshContextType {
	key: number;
	refreshRoutes: () => void;
}

/**
 * 路由刷新上下文
 * 用于在路由守卫中刷新路由树
 */
export const RouterRefreshContext = createContext<RouterRefreshContextType>({
	key: 0,
	refreshRoutes: () => { },
});

/**
 * 路由刷新上下文钩子
 * 用于在组件中获取路由刷新上下文
 */
export const useRouterRefresh = () => useContext(RouterRefreshContext);

